<%
Class Reply
'Catelog

private ThisMdb		'=	"L_cat"				'数据库
private TempPageLimit	'=	"L_cat"				'每页的条数
private sqlstr
'-------------------------------------------
Property Get PThisMdb
	PThisMdb=ThisMdb
End Property
Property Let PThisMdb(ThisMdbs)
	ThisMdb=ThisMdbs
End Property

property Get pPageLimit
	pPageLimit = TempPageLimit
End property 
property let pPageLimit(pagel)
	TempPageLimit = pagel
End property 

'
'-------------------
public Function AddNew(arrstr)				'传入一维数组
	if not isarray(arrstr) then 
		AddNew = false
		exit Function
	End if
	set rs=server.createobject("adodb.recordset")
	sqlstr ="select top 1 * from "&ThisMdb&" "
	on error resume next
	rs.open sqlstr,conn,1,3
	'if not(rs.eof and rs.bof) then 
		rs.addnew
		rs("info_id")			=	arrstr(1)
		rs("user_name")			=	arrstr(2)
		rs("reply_ip")			=	arrstr(3)
		rs("reply_content")		=	arrstr(4)
		rs.update 
	'End if 
		If Err Then
			response.write (err.Description)
			err.Clear
			AddNew = false 
		else
			AddNew = true
		End if
	rs.close
	Set rs=nothing 
End Function
public Function Delete(reply_id)
		sqlstr="delete from  "&ThisMdb&"  where [reply_id]="&reply_id&""
		on error resume next
		conn.execute(sqlstr)
		If Err Then
			response.write (err.Description)
			err.Clear
			Delete = false 
		else
			Delete = true
		End if

End Function 
public Function DeleteFromInfo(info_id)
		sqlstr="delete from  "&ThisMdb&"  where [info_id]="&info_id&""
		on error resume next
		conn.execute(sqlstr)
		If Err Then
			response.write (err.Description)
			err.Clear
			Delete = false 
		else
			Delete = true
		End if
End Function 
'---------------------
public Function GetLimitInfo(pages,strWhere)
	Dim wherestr
	If(Len(strWhere)>1) Then 
		wherestr = strWhere
	Else 
		wherestr = "(1=1)"
	End If 

	if not isnumeric(pages) then pages=1
	if pages < 1 then pages = 1 
		Dim tempall:tempall= GetAllResult(strWhere)
	if pages * TempPageLimit >tempall then pages =  tempall/TempPageLimit
	pages= int(pages+0.5)
		
		if pages <=1 then 
			sqlstr = "select top "&TempPageLimit&" [reply_id],[info_id],[user_name],[reply_content],[reply_time],[reply_ip] from "&ThisMdb&"  where "& wherestr 
		else
			sqlstr = "select top "&TempPageLimit&" [reply_id],[info_id],[user_name],[reply_content],[reply_time],[reply_ip] from "&ThisMdb&" where ([reply_id] not in (select top "&(pages-1)*TempPageLimit&" [reply_id] from "&ThisMdb&" where "& wherestr &" order by [reply_id] desc ))  and "& wherestr &""
		End if 
		sqlstr = sqlstr & " order by [reply_id] desc"

	GetLimitInfo = GetRows(sqlstr)
	
End Function 

public Function GetAllResult(strWhere)'没有递归计数
	Dim wherestr
	If(Len(strWhere)>1) Then 
		wherestr = strWhere
	Else 
		wherestr = "(1=1)"
	End If 
		sqlstr="select count(*) from "&ThisMdb&"  where " &wherestr
	GetAllResult = GetOne(sqlstr)
End Function 


public Function Edit(arrstr)
	if not isarray(arrstr) then 
		Edit = false
		exit Function
	End if
	set rs=server.createobject("adodb.recordset")
	sqlstr ="select top 1 * from "&ThisMdb&" where [reply_id]="&arrstr(0)&" "
	on error resume next
	rs.open sqlstr,conn,1,3
	if not(rs.eof and rs.bof) then 
'		rs("cat_id")			=	arrstr(1)
''		rs("user_id")			=	arrstr(2)
'		rs("info_level")		=	arrstr(3)
'		rs("info_title")		=	arrstr(4)
'		rs("info_weather")		=	arrstr(5)
'		rs("info_rank")			=	arrstr(6)
'		rs("info_content")		=	arrstr(7)
'		rs("info_ip")			=	arrstr(8)
'		rs("info_htmlorubb")	=	arrstr(9)
		rs.update 
	End if 
		If Err Then
			response.write (err.Description)
			err.Clear
			Edit = false 
		else
			Edit = true
		End if
	rs.close
	Set rs=nothing 

End Function 
'-------------------------------------------
End class
%>